package com.company;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 * Created by hehe on 2016/10/2.
 */
public class IO {
   public static  void write2Txt(String text,String path){
       try {


           File file = new File(path);

           // if file doesnt exists, then create it
           if (!file.exists()) {
               file.createNewFile();
           }

           FileWriter fw = new FileWriter(file.getAbsoluteFile());
           BufferedWriter bw = new BufferedWriter(fw);
           bw.write(text);
           bw.close();

           System.out.println("Done");

       } catch (IOException e) {
           e.printStackTrace();
       }
   }
}
